package com.hqbzl.chat.handler;

import com.hqbzl.chat.factory.Factory;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
@ChannelHandler.Sharable
@Slf4j
public class QuitHandler extends ChannelInboundHandlerAdapter {
    // 正常断开
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        Factory.session.unbind(ctx.channel());
        log.debug("{} 正常断开 ", ctx.channel());
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        Factory.session.unbind(ctx.channel());
        log.debug("{} 异常断开 ", ctx.channel(), cause);
    }
}
